package com.woniuxy.controller;

import com.github.pagehelper.PageInfo;
import com.woniuxy.entity.Records;
import com.woniuxy.service.RecordsService;
import com.woniuxy.util.PageData;
import com.woniuxy.util.RespongseData;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@AllArgsConstructor
@RequestMapping("/records")
public class RecordsController {
    private RecordsService recordsService;

    @GetMapping("/recordsPage")
    public String recordsPage() {
        return "records/records";
    }

    @PostMapping("/queryRecords")
    @ResponseBody
    public RespongseData queryRecords(@RequestBody PageData<Records> PageData){
        PageInfo<Records> recordsPageInfo = recordsService.queryRecords(PageData);
        return new RespongseData(200,"ok",recordsPageInfo);
    }

    @GetMapping("/payRecord/{id}")
    @ResponseBody
    public RespongseData payRecord(@PathVariable("id") Integer id){
        recordsService.payRecord(id);
        return new RespongseData(200,"ok",null);
    }

}
